package org.itheima.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.itheima.pojo.Result;
import org.itheima.pojo.Warehouse;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Mapper
public interface WarehouseMapper {

    @Select("SELECT * FROM jingdongdiannaoshuju\n" +
            "WHERE name LIKE CONCAT('%', #{title}, '%') AND param_info IS NOT NULL\n" +
            "UNION ALL\n" +
            "SELECT * FROM jingdongdianzishoubiaoshuju\n" +
            "WHERE name LIKE CONCAT('%', #{title}, '%') AND param_info IS NOT NULL\n" +
            "UNION ALL\n" +
            "SELECT * FROM jingdongerjishuju\n" +
            "WHERE name LIKE CONCAT('%', #{title}, '%') AND param_info IS NOT NULL\n" +
            "UNION ALL\n" +
            "SELECT * FROM jingdongjianpanshuju\n" +
            "WHERE name LIKE CONCAT('%', #{title}, '%') AND param_info IS NOT NULL\n" +
            "UNION ALL\n" +
            "SELECT * FROM jingdongpingbanshuju\n" +
            "WHERE name LIKE CONCAT('%', #{title}, '%') AND param_info IS NOT NULL\n" +
            "UNION ALL\n" +
            "SELECT * FROM jingdongshoujishuju\n" +
            "WHERE name LIKE CONCAT('%', #{title}, '%') AND param_info IS NOT NULL\n" +
            "UNION ALL\n" +
            "SELECT * FROM jingdongshubiaoshuju\n" +
            "WHERE name LIKE CONCAT('%', #{title}, '%') AND param_info IS NOT NULL;\n" +
            "\n")/*where 标题 like CONCAT('%', #{title}, '%')*/
    List<Map<String, Object>> findByTitle(String title);  // 返回 List<Warehouse>

    @Select("SELECT * FROM jingdongdiannaoshuju\n" +
            "UNION ALL\n" +
            "SELECT * FROM jingdongdianzishoubiaoshuju\n" +
            "UNION ALL\n" +
            "SELECT * FROM jingdongerjishuju\n" +
            "UNION ALL\n" +
            "SELECT * FROM jingdongjianpanshuju\n" +
            "UNION ALL\n" +
            "SELECT * FROM jingdongpingbanshuju\n" +
            "UNION ALL\n" +
            "SELECT * FROM jingdongshoujishuju\n" +
            "UNION ALL\n" +
            "SELECT * FROM jingdongshubiaoshuju\n" +
            "\n")/*where 标题 like CONCAT('%', #{title}, '%')*/
    List<Map<String, Object>> findAll();  // 返回 List<Warehouse>

    @Select("SELECT * FROM jingdongdiannaoshuju WHERE number LIKE '%10万%'\n" +
            "UNION ALL\n" +
            "SELECT * FROM jingdongdianzishoubiaoshuju WHERE number LIKE '%10万%' AND param_info IS NOT NULL\n" +
            "UNION ALL\n" +
            "SELECT * FROM jingdongerjishuju WHERE number LIKE '%10万%' AND param_info IS NOT NULL\n" +
            "UNION ALL\n" +
            "SELECT * FROM jingdongjianpanshuju WHERE number LIKE '%10万%' AND param_info IS NOT NULL\n" +
            "UNION ALL\n" +
            "SELECT * FROM jingdongpingbanshuju WHERE number LIKE '%10万%' AND param_info IS NOT NULL\n" +
            "UNION ALL\n" +
            "SELECT * FROM jingdongshoujishuju WHERE number LIKE '%10万%' AND param_info IS NOT NULL\n" +
            "UNION ALL\n" +
            "SELECT * FROM jingdongshubiaoshuju WHERE number LIKE '%10万%' AND param_info IS NOT NULL;\n")
    List<Map<String, Object>> HotItems(String NumberOfComments);

    @Insert("insert into usersearchhistory(user_id,search_term,search_time) values (#{user_id},#{researchData},now())")
    void chaRuSouSuoJiLu(int user_id,String researchData);

    @Select("select * from jingdongdiannaoshuju WHERE name LIKE CONCAT('%', #{title}, '%')")
    List<Map<String, Object>> jingdongdiannaoshuju(String title);


    @Select("select * from jingdongdianzishoubiaoshuju WHERE name LIKE CONCAT('%', #{title}, '%')")
    List<Map<String, Object>> jingdongdianzishoubiaoshuju(String title);

    @Select("select * from jingdongerjishuju WHERE name LIKE CONCAT('%', #{title}, '%')")
    List<Map<String, Object>> jingdongerjishuju(String title);

    @Select("select * from jingdongjianpanshuju WHERE name LIKE CONCAT('%', #{title}, '%')")
    List<Map<String, Object>> jingdongjianpanshuju(String title);

    @Select("select * from jingdongpingbanshuju WHERE name LIKE CONCAT('%', #{title}, '%')")
    List<Map<String, Object>> jingdongpingbanshuju(String title);

    @Select("select * from jingdongshoujishuju WHERE name LIKE CONCAT('%', #{title}, '%')")
    List<Map<String, Object>> jingdongshoujishuju(String title);

    @Select("select * from jingdongshubiaoshuju WHERE name LIKE CONCAT('%', #{title}, '%')")
    List<Map<String, Object>> jingdongshubiaoshuju(String title);

    @Select("select * from taobaodiannaoshuju WHERE name LIKE CONCAT('%', #{title}, '%')")
    List<Map<String, Object>> taobaodiannaoshuju(String title);

    @Select("select * from taobaodianzishoubiaoshuju WHERE name LIKE CONCAT('%', #{title}, '%')")
    List<Map<String, Object>> taobaodianzishoubiaoshuju(String title);

    @Select("select * from taobaoerjishuju WHERE name LIKE CONCAT('%', #{title}, '%')")
    List<Map<String, Object>> taobaoerjishuju(String title);

    @Select("select * from taobaojianpanshuju WHERE name LIKE CONCAT('%', #{title}, '%')")
    List<Map<String, Object>> taobaojianpanshuju(String title);


    @Select("select * from taobaopingbanshuju WHERE name LIKE CONCAT('%', #{title}, '%')")
    List<Map<String, Object>> taobaopingbanshuju(String title);

    @Select("select * from taobaoshoujishuju WHERE name LIKE CONCAT('%', #{title}, '%')")
    List<Map<String, Object>> taobaoshoujishuju(String title);


    @Select("select * from taobaoshubiaoshuju WHERE name LIKE CONCAT('%', #{title}, '%')")
    List<Map<String, Object>> taobaoshubiaoshuju(String title);





}
